<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>犯人账户</title>
    <th:block th:include="~{common/common::commonHead}"/>
</head>
<!-- /Head -->
<!-- Body -->
<body>
<!-- Page Body -->
<div class="page-body">
    <div class="panel panel-primary">
        <div class="panel-heading bg-blue">
            犯人账户
        </div>
        <div class="widget-body grid-table">
            <div class="toolbar">
                <div class="fl-left">
                    <!--<button data-menu-id="070401" data-click="add('prisoner/prisonerAdd.html','prisonerAccount')"-->
                            <!--class="btn btn-default shiny">新建账户-->
                    <!--</button>-->
                    <button data-menu-id="070408" data-click="add1('prisoner/capitalFlowAdd.html','prisonerAccount')"
                            class="btn btn-default shiny">代发代扣
                    </button>
                    <button data-menu-id="070402" data-click="import('prisonerList','goods/batchDelGoods')"
                            class="btn btn-blue shiny">批量导入
                    </button>
                    <button data-menu-id="070403" data-click="export('prisonerList','goods/batchDelGoods')"
                            class="btn btn-blue shiny">批量开户
                    </button>
                    <button data-menu-id="070404" data-click="export('prisonerList','goods/batchDelGoods')"
                            class="btn btn-blue shiny">补卡挂失
                    </button>
                    <button data-menu-id="070405" data-click="export('prisonerList','goods/batchDelGoods')"
                            class="btn btn-danger shiny">离监销户
                    </button>
                    <button data-menu-id="070406" data-click="add('prisoner/prisonerThresholdEdit.html','prisonerId')"
                            class="btn btn-blue shiny">批量设置阈值
                    </button>
                    <button data-menu-id="070407" data-click="del('prisonerList','goods/batchDelGoods')"
                            class="btn btn-danger shiny">批量清除阈值
                    </button>
                </div>
                <div class="toolbar-right">
                    <div class="fl-right">
                        <div class="btn-group" role="group">
                            <button data-click="toggleFilter()" class="btn btn-default text-center">
                                <i class="fa fa-filter fa-fw"></i>
                            </button>
                            <button data-click="refresh('prisonerAccount')" class="btn btn-default">
                                <i class="fa fa-refresh fa-fw"></i>
                            </button>
                            <button data-click="download('prisonerAccount')" class="btn btn-default">
                                <i class="fa fa-download fa-fw"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div id="prisonerAccount"></div>
            <form class="filter search-content form-horizontal" role="form">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label"> 犯人姓名 </label>
                        <div class="col-xs-8">
                            <div class="iconic-input right">
                                <input name="prisonerName" type="text" class="form-control spinner"
                                       placeholder="请输入犯人姓名">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label"> 监区 </label>
                        <div class="col-xs-8">
                            <select name="room" class="form-control spinner" data-url="prisonerInfo/listPrisonerInfo" data-value-field="room" data-text-field="room" >
                                <option value="">全部</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label"> 监仓 </label>
                        <div class="col-xs-8">
                            <select name="goodsStatus" class="form-control spinner">
                                <option value="-1">全部</option>
                                <option value="1">一监仓</option>
                                <option value="2">二监仓</option>
                                <option value="3">三监仓</option>
                                <option value="3">四监仓</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label"> 监室 </label>
                        <div class="col-xs-8">
                            <select name="goodsStatus" class="form-control spinner">
                                <option value="-1">全部</option>
                                <option value="1">一监室</option>
                                <option value="2">二监室</option>
                                <option value="3">三监室</option>
                                <option value="3">四监室</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label"> 开户状态 </label>
                        <div class="col-xs-8">
                            <select name="goodsStatus" class="form-control spinner">
                                <option value="-1">全部</option>
                                <option value="1">已开户</option>
                                <option value="2">未开户</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <button type="button" data-click="hideFilter()" class="btn btn-default pull-right">取消</button>
                    <button type="button" data-click="submitFilter('prisonerAccount')" class="btn btn-blue pull-right">确定
                    </button>
                </div>
            </form>
        </div>
    </div><!-- end of panel -->
    <!-- /Page Container -->
    <!-- Main Container -->

</div>
</body>
<!--  /Body -->
</html>
<script>
    $(function () {
        $("#prisonerAccount").gridTable({
            url: "prisonerAccount/pagePrisonerAccount",
            columns: [
                {title: "犯人编号", field: "id"},
                {title: "犯人姓名", field: "prisonerName"},
                {title: "账户", field: "bankCard"},
                {title: "开户行", field: "bankName"},
                {title: "余额", field: "balance",dataType:"decimal"},
                {title: "A类", field: "aLevel",dataType:"decimal"},
                {title: "B类", field: "bLevel",dataType:"decimal"},
                {title: "C类", field: "cLevel",dataType:"decimal"},
                {title: "冻结金额", field: "freezingAmount",dataType:"decimal"},
                {title: "可用金额", field: "availableAmount",dataType:"decimal"},
                {title: "消费阈值", field: "consumptionThreshold",dataType:"decimal"}
            ],
            idField: "id",
            infoUrl: "prisoner/prisonerInfo.html",

            delUrl: "prisoner/delPrisoner",
            controls:{
                del:{
                    text:"销户"
                },
                edit:{
                    show:false
                }
            }
        });
    });
    //代发代扣
    function add1() {
        var gridTable = $$selection.get("gridTable","prisonerAccount");
        var selectedRows = gridTable.getSelectedRows();
        if (selectedRows.length === 0) {
            $.error("请选择一条数据");
            return false
        }
        if (selectedRows.length > 1) {
            $.error("只允许选择一条数据");
            return false
        }
        var row = selectedRows[0];
        var id = row.getData().id;
        var dialog = $.openIframeDialog({
            title:"资金流动记录",
            url: "prisoner/capitalFlowAdd.html",
//            param: {
//                idStr: id
//            },
            buttons: {
                ok: {
                    onclick: function () {
                        var form = $("form", dialog.getSubPage())[0];
                        var flowType = $("#flowType", form).val();
                        var aa= $("#flowMoney",form).val();
                        var flowMoney = (Number (aa))*100;
                        var flow ={
                            flowType:flowType,
                            flowMoney:flowMoney,
                            prisonerId:id
                        };
                        $.doAjax("prisonerCapitalFlow/addPrisonerCapitalFlow",flow,function(data){
                            gridTable.reloadData();
                        });
                        dialog.close();
                    }
                }
            }
       });
    }
</script>